﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
										xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
										xmlns:local="clr-namespace:DaveSexton.Labs">

	<Style TargetType="{x:Type local:WindowsConsoleLab}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:WindowsConsoleLab}">
					<ControlTemplate.Resources>

						<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
						<local:InverseBooleanConverter x:Key="InverseBooleanConverter" />

					</ControlTemplate.Resources>

					<Border Background="{TemplateBinding Background}"
									BorderBrush="{TemplateBinding BorderBrush}"
									BorderThickness="{TemplateBinding BorderThickness}">

						<Grid>
							<Border BorderBrush="LightSteelBlue" BorderThickness="2" Padding="2"
											HorizontalAlignment="Center" VerticalAlignment="Center"
											MaxWidth="500">
								<Border BorderBrush="White" BorderThickness="5" Padding="10 20 10 0"
												HorizontalAlignment="Center" VerticalAlignment="Center">

									<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">

										<TextBlock HorizontalAlignment="Center" FontSize="20" FontWeight="Bold" Text="{TemplateBinding DisplayName}" />

										<TextBlock HorizontalAlignment="Center" FontSize="18" Text="{TemplateBinding FullCategory}" />

										<ComboBox ItemsSource="{TemplateBinding Experiments}"
															SelectedItem="{Binding SelectedExperiment, RelativeSource={RelativeSource TemplatedParent}}"
															IsEnabled="{Binding IsRunning, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBooleanConverter}}"
															Visibility="{Binding HasExperiments, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter}}"
															Margin="0 5 0 0">
											<ComboBox.ItemTemplate>
												<DataTemplate DataType="local:IExperiment">
													<TextBlock Text="{Binding DisplayName}" />
												</DataTemplate>
											</ComboBox.ItemTemplate>
										</ComboBox>

										<TextBlock HorizontalAlignment="Center" FontSize="15" Text="{TemplateBinding Description}"
															 Margin="10" TextWrapping="Wrap" />

										<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">

											<Button Grid.Column="0" Margin="20 20"
															Name="PART_Start"
															IsEnabled="{Binding IsRunning, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource InverseBooleanConverter}}">
												<Button.Style>
													<Style TargetType="Button">
														<Setter Property="MinWidth" Value="150" />
														<Setter Property="Height" Value="70" />
														<Setter Property="FontSize" Value="17" />
														<Setter Property="Background" Value="#F1FFFA" />
														<Setter Property="Content" Value="Start Experiment" />
														<Style.Triggers>
															<DataTrigger Binding="{Binding HasExperiments, RelativeSource={RelativeSource TemplatedParent}}" Value="False">
																<Setter Property="Content" Value="Start Lab" />
															</DataTrigger>
															<DataTrigger Binding="{Binding SelectedExperiment.DisplayName, RelativeSource={RelativeSource TemplatedParent}}" Value="Main">
																<Setter Property="Content" Value="Start Lab" />
															</DataTrigger>
														</Style.Triggers>
													</Style>
												</Button.Style>
											</Button>

										</StackPanel>

									</StackPanel>

								</Border>
							</Border>

							<DockPanel HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Margin="4"
												 Visibility="{TemplateBinding WaitingForUserInput, Converter={StaticResource BooleanToVisibilityConverter}}">

								<TextBlock DockPanel.Dock="Left" VerticalAlignment="Center" FontSize="14" Text="Input: " />

								<TextBox Name="PART_Input" />

							</DockPanel>
						</Grid>

					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="{x:Type local:WindowsLabHost}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:WindowsLabHost}">
					<ControlTemplate.Resources>

						<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
						<local:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" />

						<Style TargetType="ComboBoxItem" BasedOn="{x:Null}" />

						<SolidColorBrush x:Key="ContentBorderBrush" Color="{x:Static SystemColors.WindowFrameColor}" />

						<DataTemplate x:Key="LabTemplate">
							<TextBlock>
								<Run Text="{Binding OrganizedName, Mode=OneWay}" />
							</TextBlock>
						</DataTemplate>

						<Style x:Key="Output" TargetType="RichTextBox">
							<Setter Property="FontFamily" Value="Courier New" />
							<Setter Property="AcceptsReturn" Value="True" />
							<Setter Property="IsReadOnly" Value="True" />
							<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
						</Style>

						<Style x:Key="Source" TargetType="TextBox">
							<Setter Property="FontFamily" Value="Courier New" />
							<Setter Property="AcceptsReturn" Value="True" />
							<Setter Property="IsReadOnly" Value="True" />
							<Setter Property="HorizontalScrollBarVisibility" Value="Auto" />
							<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
							<Setter Property="ContextMenu">
								<Setter.Value>
									<ContextMenu>
										<MenuItem Header="Copy Selection" Command="Copy">
											<MenuItem.Icon>
												<Image Source="pack://application:,,,/DaveSexton.Labs;component/Images/Copy16x16.png" />
											</MenuItem.Icon>
										</MenuItem>
										<MenuItem Header="Select All" Command="SelectAll" />
									</ContextMenu>
								</Setter.Value>
							</Setter>
						</Style>

					</ControlTemplate.Resources>

					<Border Background="{TemplateBinding Background}"
									BorderBrush="{TemplateBinding BorderBrush}"
									BorderThickness="{TemplateBinding BorderThickness}">

						<DockPanel>

							<DockPanel DockPanel.Dock="Top" Margin="10 10 10 5">

								<TextBlock VerticalAlignment="Center" Padding="0 0 10 0">
									Current lab:
								</TextBlock>

								<ComboBox Name="PART_Labs" Style="{x:Null}"
													IsEnabled="{TemplateBinding CanChangeLab}"
													ItemsSource="{TemplateBinding Labs}"
													ItemTemplate="{StaticResource LabTemplate}" />

							</DockPanel>

							<Grid Margin="0 5 0 0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="*" MinWidth="25" />
									<ColumnDefinition Width="Auto" />
									<ColumnDefinition Width="*" MinWidth="25" />
								</Grid.ColumnDefinitions>
								<Grid.RowDefinitions>
									<RowDefinition Height=".75*" MinHeight="25" />
									<RowDefinition Height="Auto" />
									<RowDefinition Height="*" MinHeight="25" />
								</Grid.RowDefinitions>

								<Border Grid.Row="0" Grid.ColumnSpan="3"
												BorderBrush="{StaticResource ContentBorderBrush}" BorderThickness="1">

									<ContentControl Content="{Binding SelectedItem.ActualLab, ElementName=PART_Labs}"
																	VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" />

								</Border>

								<GridSplitter Grid.Row="1" Grid.ColumnSpan="3" Height="9"
															HorizontalAlignment="Stretch" VerticalAlignment="Center" />

								<RichTextBox Name="PART_Output" Grid.Row="2" Grid.Column="0" Style="{StaticResource Output}">
									<RichTextBox.ContextMenu>
										<ContextMenu>
											<MenuItem Header="Copy Selection" Command="Copy">
												<MenuItem.Icon>
													<Image Source="pack://application:,,,/DaveSexton.Labs;component/Images/Copy16x16.png" />
												</MenuItem.Icon>
											</MenuItem>
											<MenuItem Header="Select All" Command="SelectAll" />
											<Separator />
											<MenuItem Header="Clear All" Command="Delete">
												<MenuItem.Icon>
													<Image Source="pack://application:,,,/DaveSexton.Labs;component/Images/ClearAll16x16.png" />
												</MenuItem.Icon>
											</MenuItem>
										</ContextMenu>
									</RichTextBox.ContextMenu>
								</RichTextBox>

								<GridSplitter Grid.Row="2" Grid.Column="1" Width="9"
															VerticalAlignment="Stretch" HorizontalAlignment="Center" 
															Visibility="{TemplateBinding HasSourceCode, Converter={StaticResource BooleanToVisibilityConverter}}" />

								<TabControl Grid.Row="2" Grid.Column="2" TabStripPlacement="Bottom" BorderThickness="2"
														Visibility="{TemplateBinding HasSourceXaml, Converter={StaticResource BooleanToVisibilityConverter}}">

									<TabItem Header="XAML" Visibility="{TemplateBinding HasSourceXaml, Converter={StaticResource BooleanToVisibilityConverter}}">

										<TextBox Text="{TemplateBinding SourceXaml}" Style="{StaticResource Source}" />

									</TabItem>

									<TabItem Header="Code" Visibility="{TemplateBinding HasSourceCode, Converter={StaticResource BooleanToVisibilityConverter}}">

										<TextBox Text="{TemplateBinding SourceCode}" Style="{StaticResource Source}" />

									</TabItem>

								</TabControl>

								<TextBox Grid.Row="2" Grid.Column="2"
												 Visibility="{TemplateBinding HasSourceXaml, Converter={StaticResource InverseBooleanToVisibilityConverter}}"
												 Text="{TemplateBinding SourceCode}" Style="{StaticResource Source}" />

							</Grid>

						</DockPanel>

					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>